#include "common.h"
#include <QMessageBox>

QString FormatTime(int time)
{
    QDateTime dt = QDateTime::fromTime_t(time);
    int days = dt.toString("dd").toInt();
    int hours = dt.toString("hh").toInt();
    int minutes = dt.toString("mm").toInt();
    int seconds = dt.toString("ss").toInt();
    QString ret;
    if(days)
        ret += QObject::tr("%1 days ").arg(days);
    if(hours)
        ret += QObject::tr("%1:").arg(hours);
    ret += QString("%1:%2").arg(minutes).arg(seconds);
    return ret;
}

void DebugMsgBox(const QString& text)
{
    QMessageBox mbox;
    mbox.setText(text);
    QEventLoop el;
    QObject::connect(&mbox, SIGNAL(accepted()), &el, SLOT(quit()));
    QObject::connect(&mbox, SIGNAL(rejected()), &el, SLOT(quit()));
    QObject::connect(&mbox, SIGNAL(finished(int)), &el, SLOT(quit()));
    mbox.show();
    el.exec();
}
